package com.atguigu.lease.web.admin.custom.converter;

import com.atguigu.lease.model.enums.ReleaseStatus;
import org.springframework.core.convert.converter.Converter;
/**
 * projectName: com.atguigu.lease.web.admin.custom.converter
 *
 * @author: 吴振鹏
 * description:
 * time: 2025/7/9 15:58
 */

public class StringToReleaseStatusConverter implements Converter<String, ReleaseStatus> {
    @Override
    public ReleaseStatus convert(String source) {
        ReleaseStatus[] statuses = ReleaseStatus.values();
        for(ReleaseStatus status : statuses){
            if(status.getCode()==Integer.parseInt(source)){
                return status;
            }
        }
        throw new RuntimeException("非法参数异常，仅支持0,1");

    }
}
